#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main()
{
	int T;
	cin >> T;
	stack<int>st;
	for (int t = 0; t < T; t++) {
		int n;
		cin >> n;
		for (int i = 0; i < n; i++) {
			string str;
			cin >> str;
			if (str == "push") {
				int x;
				cin >> x;
				st.push(x);
			}
			else if (str == "pop") {
				if (st.empty()) cout << "Empty" << endl;
				else st.pop();
			}
			else if (str == "query") {
				if (st.empty()) cout << "Anguei!" << endl;
				else cout << st.top();
			}
			else if (str == "size") cout << st.size() << endl;
		}
	}
	return 0;
}